package thread;

class ThreadDemo extends Thread{
    public void run(){      //线程的入口
        while (true){
            try {
                Thread.sleep(1000);     //由于父类的run方法中没有throws异常，在这里不可用throws
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
            System.out.println("hello run");
        }
    }
}
public class demo1 {
    public static void main(String[] args) throws InterruptedException {
        Thread t1 = new ThreadDemo();
        t1.start();
        while (true){
            Thread.sleep(1000);     //这里的main方法为自己创建，可以throws
            System.out.println("hello thread");
        }
    }
}
